import { reactive, onMounted, defineComponent, toRefs, getCurrentInstance } from 'vue'
import logApi from '@/api/inwarehouse/log-api'
import ZlrtTable from '@/components/zlrt-table/table.vue'
import ZlrtSearch from '@/components/zlrt-search/search.vue'
import TableContext from '@/components/zlrt-table/table-context'

export default defineComponent({
  components: {
    ZlrtTable,
    ZlrtSearch
  },
  setup() {

    const ctx = reactive(new TableContext(getCurrentInstance(), {
      title: '出入库记录',
      api: logApi,
      columns: [
        { prop: 'operate', label: '出/入库', slot: true, width: 90 },
        { prop: 'areaName', label: '库区', valueType: 'input', width: 120},
        { prop: 'locationName', label: '库位名称', valueType: 'input', width: 200},
        { prop: 'locationCode', label: '库位编码', width: 120 },
        { prop: 'skuName', label: '物料名称', valueType: 'input' },
        { prop: 'barCode', label: '物料编码', valueType: 'input', width: 120 },
        { prop: 'specification', label: '规格型号', width: 200 },
        { prop: 'number', label: '数量', width: 90 },
        { prop: 'unit', label: '单位', width: 90 }
      ],
      rules: {
      }
    }))

    const data = reactive({
      ctx,
      warehouseOptions: [],
      ownerOptions: []
    })

    // init
    onMounted(() => {
      ctx.loadData()
    })

    return {
      ...toRefs(data)
    }
  }
})
